<script setup lang="ts">
import {ref} from 'vue'
import Son from './son.vue'

// 通过typeof获取到组件对象的类型 然后配合内置的InstanceType得到组件实例类型
type SonInstanceType = InstanceType<typeof Son>

const sonRef = ref<SonInstanceType | null>(null)

const initSonDataHandler = ()=>{
  sonRef.value?.initData()
}
</script>

<template>
  <Son ref="sonRef" />
  <button @click="initSonDataHandler">initData</button>
</template>
